﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using Avatar.Model;
using AvatarHelper;

namespace Avatar.BLL
{
    public class SiteGroupManager
    {
        /// <summary>
        /// 获取当前站点名称
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static string GetCurrentSiteName() 
        {
            string _host = "www";

            string url = HttpContext.Current.Request.Url.Host;
            if(url.Split('.').Length == 3) 
            {
                int start = url.IndexOf('.');
                _host = url.Substring(0, start);
            }

            return _host;
        }

        /// <summary>
        /// 获取当前站点信息
        /// </summary>
        /// <returns></returns>
        //public static Host GetCurrentSite()
        //{
        //    string _siteName = "www";

        //    string url = HttpContext.Current.Request.Url.Host;
        //    if(url.Split('.').Length == 3) 
        //    {
        //        int start = url.IndexOf('.');
        //        _siteName = url.Substring(0, start);
        //    }

            //return DBHelper.Get<Host>(h => h.Host_EnName == _siteName, "获取当前站点信息出错！");
        //}
        /// <summary>
        /// 获取网站Logo
        /// </summary>
        /// <returns></returns>
        public static string GetLogo()
        {
            string _logo = "../images/title.gif";

            //var _site = GetCurrentSite();
            //if (_site != null)
            //{
            //    if(!string.IsNullOrEmpty(_site.Host_Img)) _logo = "../images/CityLogo/" + _site.Host_Img;
            //}
            return _logo;
        }
    }
}
